//
//  CreateLikeCategory.swift
//  StorePlan
//
//  Created by admin on 2020/9/25.
//  Copyright © 2020 admin. All rights reserved.
//

import SwiftUI
import Alamofire
struct CreateLikeCategory: View {
    
    @State var name:String = "cesi"

    func createikeCategory(){
        AF.request("\(baseURL)sharelike/addcategory",method: .post,parameters: ["name":name])
            .responseData { response in
                switch response.result {
                case .success:
                    print("Validation Successful\(response.result)")
                case let .failure(error):
                    print(error)
                }
            }
    }
    
    var body: some View {
        VStack {
            
            InputView(title: "名称：", plstr: "名称", value: $name)
                .frame(maxWidth: .infinity, alignment: .center)

            Button(action: {
                createikeCategory()
            }) {
                
                Text("保存")
                    .foregroundColor(Color.white)
            }
            .frame(width: 320.0, height:44)
            .background(Color.red)
            .cornerRadius(8)
            .padding(8)
           
            
            Spacer()
        }
        .padding()
        .background(Color.init(red: 0.9, green: 0.9, blue: 0.9))
        .navigationBarTitle(Text("新增"))
       
    }
}

struct CreateLikeCategory_Previews: PreviewProvider {
    static var previews: some View {
        CreateLikeCategory()
    }
}
